package com.um.jdy.platform.order.controller;


import com.um.jdy.platform.order.entity.dto.CommissionOrderPageDTO;
import com.um.jdy.platform.order.entity.dto.CommissionSummaryPageDTO;
import com.um.jdy.platform.order.entity.vo.OrderCommissionItemVO;
import com.um.jdy.platform.order.entity.vo.PartnersCommissionPageVO;
import com.um.jdy.platform.order.entity.vo.PartnersCommissionSummaryVO;
import com.um.jdy.platform.order.manager.OrderCommissionManager;
import com.um.springboot.starter.annotation.ApiPermission;
import com.um.springboot.starter.annotation.TokenRequired;
import com.um.springboot.starter.entity.Page;
import com.um.springboot.starter.orm.controller.BaseController;
import com.um.springboot.starter.orm.entity.Response;
import com.um.springboot.starter.orm.params.PageParams;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 控制器：订单佣金表
 */
@RestController
@RequestMapping("/api/v1/cms/order/order_commission")
@Api(tags = "佣金管理", description = "订单佣金表")
@ApiPermission("charge_commissions")
@TokenRequired
@Validated
public class OrderCommissionController extends BaseController<OrderCommissionManager> {

    /**
     * 查询充电订单佣金明细列表
     * @param id 订单ID
     * @return
     */
    @ApiPermission("list")
    @ApiOperation("查询充电订单佣金明细列表")
    @GetMapping("/list/{id}")
    public Response<List<OrderCommissionItemVO>> getCommissionList(@PathVariable String id){
        return manager.getCommissionList(id);
    }



    /**
     * 分页查询运营商佣金明细
     * @param params
     * @return
     */
    @ApiPermission("page")
    @ApiOperation("分页查询运营商佣金明细")
    @PostMapping("/merchant_page")
    public Response<PartnersCommissionPageVO> getMerchantPage(@RequestBody CommissionOrderPageDTO params){
        PageParams pageParams = params.toPageParams(
                new String[]{"platformMerchantId","orderNo","outTradeNo","nickname","mobile","status","type","deviceCode"},
                new String[]{"mm.platform_merchant_id","o.order_no","o.out_trade_no","u.nickname","u.mobile","o.status","type","o.device_code"},
                "o.create_time","beginTime","endTime");
        return manager.getMerchantPage(pageParams);
    }



    /**
     * 分页查询运营商佣金统计
     * @param params
     * @return
     */
    @ApiPermission("summary")
    @ApiOperation("分页查询运营商佣金统计")
    @PostMapping("/merchant_summary_page")
    public Response<Page<PartnersCommissionSummaryVO>> getMerchantSummaryPage(@RequestBody CommissionSummaryPageDTO params){
        return manager.getMerchantSummaryPage(params);
    }

}
